#!/usr/bin/env python 

""""
Copyright 2010-2011 Vincent Gauthier
Email: vincent.gauthier@telecom-sudparis.eu
"""

import numpy as np
from pylab import *

meanVal = 6.0
standartDev = 9.0

randomSample = np.random.normal(meanVal, standartDev, 100)
nbSample = arange(1,len(randomSample)+1)

samplemean = sum(randomSample)/len(randomSample)
samplevariance = (1.0/(len(randomSample)-1)) * sum([(val-samplemean)**2 for val in randomSample])

# the 95th quantile of the student-t distribution with 99 degree of liberty is 1.660
confidenceinterval = (samplemean + 1.660*sqrt(samplevariance)/sqrt(len(randomSample)), samplemean - 1.660*sqrt(samplevariance)/sqrt(len(randomSample))) 

text = "the confidence interval is [" + str(confidenceinterval[0]) + " , " + str(confidenceinterval[1]) + "]"

fig = figure()
plot(cumsum(randomSample)/nbSample)
xlabel('X')
ylabel('Y')
title(text)
show() 
